<template>
	<gui-page :refresh="true" @reload="reload" :loadmore="true" @loadmorefun="loadData"
		:apiLoadingStatus="apiLoadingStatus" ref="guipage">
		<template v-slot:gFixedTop>
			<gui-a-header title="关注人才"></gui-a-header>
		</template>
		<template v-slot:gBody>
			<view class="post-list pad-post">
				<gui-empty v-if="noData">
					<template v-slot:img>
						<view class="gui-flex gui-rows gui-justify-content-center">
							<image class="nodata-img" src="../../static/image/no_curriculum_vitae.png" mode="widthFix">
							</image>
						</view>
					</template>
					<template v-slot:text>
						<text class="gui-text-small gui-block gui-text-center gui-margin-top gui-color-gray">暂无数据</text>
					</template>
				</gui-empty>
				<view class="deliver-list bgfff">
					<view class="deliver-item gui-flex gui-align-items-start" v-for="(item,index) in dataList"
						:key="item.id">
						<view class="photo">
							<gui-image :width="115" :height="115" :src="item.userImg" borderRadius="60rpx"
								mode="aspectFill"></gui-image>
							<image class="sex_img" v-if="item.userSex == '0'" src="../../static/image/man.png" mode="widthFix"></image>
							<image class="sex_img" v-if="item.userSex == '1'" src="../../static/image/woman.png" mode="widthFix"></image>
						</view>
						<view class="info">
							<view class="f26 c333">
								{{item.userName}}
							</view>
							<view class="f22 stress mt10" v-if="item.comUserCompanyList.length > 0">
								期望地点：{{item.comUserCompanyList[0].postName}}
							</view>
							<view class="f22 c666 mt10" v-if="item.comUserJobHuntList.length > 0">
								期望职位：{{item.comUserJobHuntList[0].addressName}}
							</view>
							<view class="sgin gui-flex">
								<view class="sgin-item" v-if="item.userAge">
									{{item.userAge}}
								</view>
								<view class="sgin-item" v-if="item.workTime">
									{{item.workTime}}
								</view>
								<view class="sgin-item" v-if="item.education">
									{{item.education}}
								</view>
								<view class="sgin-item stress-warp" v-if="item.workStatus">
									{{item.workStatus}}
								</view>
							</view>
							<view class="btn_pos">
								<button class="show_btn f20 cfff" @click="$u.to(`/pages/mine/curriculumVitae/curriculum-vitae?type=firm&id=${item.id}`)">查看</button>
							</view>
						</view>
					</view>
				</view>
			</view>
		</template>
	</gui-page>
</template>

<script setup>
	import {
		ref,
		reactive,
		inject
	} from 'vue'
	import {
		onLoad,
		onUnload
	} from '@dcloudio/uni-app'
	import {
		selectUserFollowList
	} from '@/api/company.js'
	const guipage = ref(null);
	const apiLoadingStatus = ref(false)
	const $u = reactive(inject('$u'))
	const reload = (isRelod = true) => {
		query.value.pageNum = 1;
		loadData(isRelod);
	}
	const query = ref({
		pageNum: 1,
		pageSize: 10,
		postName: ''
	})
	const noData = ref(false);
	const dataList = ref([])
	// 搜索框输入
	const inputting = (e) => {
		query.value.postName = e;
	}
	// 搜索框确认
	const confirm = (e) => {
		console.log(e);
		query.value.postName = e;
		reload(false);
	}
	// 搜索清空
	const clear = (e) => {
		query.value.postName = '';
		reload(false);
	}
	// 查询
	const loadData = (isReload) => {
		let queryParam = Object.assign(query.value, {})
		selectUserFollowList(queryParam).then(res => {
			if (res.code == 200) {
				var resultArr = res.rows;
				let total = Math.ceil(res.total / queryParam.pageSize);
				if (queryParam.pageNum >= 2) {
					dataList.value = dataList.value.concat(resultArr);
					guipage.value.stoploadmore();
					if (queryParam.pageNum >= total) {
						guipage.value.nomore();
					}
				}
				else {
					dataList.value = [];
					dataList.value = resultArr;
					// 刷新
					if (isReload) {
						guipage.value.endReload();
					} else {
						guipage.value.stoploadmore();
					}
					(resultArr.length <= 0) ? noData.value = true: noData.value = false;
				}
				query.value.pageNum++;
			}
		})
	}
	const goEdit = (item) => {
		$u.to(`/pages/firm/post-send?postId=${item.id}`)
	}
	
	onLoad(() => {
		uni.$on('updatePost', () => {
			reload();
		})
		loadData();
	})
	
	onUnload(() => {
		uni.$off('updatePost')
	})
	
</script>

<style lang="scss">
	.search {
		padding: 28rpx 14rpx 24rpx 36rpx;

		.border {
			border: 1px solid #ccc;
		}

		.saveBtn {
			width: 97rpx;
			height: 53rpx;
			margin-left: 10rpx;
			font-size: 20rpx;
		}
	}

	.shai {
		padding: 20rpx 10rpx 14rpx 36rpx;

		.la {
			position: relative;
			top: -4rpx;
		}

		.label-item {
			padding: 6rpx 14rpx;
			background: #F5F5F5;
			border-radius: 14rpx;
			margin-left: 10rpx;
			margin-bottom: 10rpx;
		}

		.tool {
			position: relative;
			top: -4rpx;

			.tool-text {
				position: relative;
				padding: 6rpx 15rpx;

				&:last-child::before {
					content: "";
					position: absolute;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
					width: 1px;
					height: 24rpx;
					background: #D50000;
				}
			}
		}
	}

	.deliver-list {
		padding: 0 36rpx;
		margin-top: 10rpx;
		box-sizing: border-box;
	}
</style>